#define _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>
#include<stdlib.h>
typedef struct TreeNode
{
    char data;
    struct TreeNode* left;
    struct TreeNode* right;
}BitreeNode, * BiTree;
int BiTreeCreate(BiTree* bt);
void BiTraverse(BiTree bt);
void swap(BiTree bt);
int main()
{
    BiTree root = NULL;
    BiTreeCreate(&root);
    BiTraverse(root);
    swap(root);
    printf("\n");
    BiTraverse(root);
    return 0;
}
int BiTreeCreate(BiTree* bt)
{
    char ch;
    scanf("%c", &ch);
    if (ch == '#')
    {
        (*bt) = NULL;
    }
    else
    {
        (*bt) = (BiTree)malloc(sizeof(BitreeNode));
        if ((*bt) == NULL)
            return 0;
        (*bt)->data = ch;
        (*bt)->left = NULL;
        (*bt)->right = NULL;
        BiTreeCreate(&((*bt)->left));
        BiTreeCreate(&((*bt)->right));
    }
    return 1;
}
void BiTraverse(BiTree bt)
{
    if (bt == NULL)
    {
        return;
    }
    BiTraverse(bt->left);
    printf("%c", bt->data);
    BiTraverse(bt->right);
}
void swap(BiTree bt)
{
    if (bt == NULL)
        return;
    BiTree m;
    m = bt->left;
    bt->left = bt->right;
    bt->right = m;
    swap(bt->left);
    swap(bt->right);
}